#include <stdlib.h>

#include <ctype.h>
#include <stdbool.h>

int atoi( const char *nptr ) {
  int ret = 0;
  bool neg;
  while( isblank( *nptr ) )
  { nptr++; }
  neg = ( *nptr == '-' );
  if( *nptr == '-' || *nptr == '+' )
  { nptr++; }
  while( isdigit( *nptr ) )
  { ret = ret * 10 + ( *( nptr++ ) - '0' ); }
  return ( neg ? -ret : ret ); // Since -INT_MIN is INT_MIN in sdcc, the result value always turns out ok.
}

